# TCP连接
import socket


def start_client():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    sock.connect(('127.0.0.1', 9527))

    recv_bytes = sock.recv(1024)

    print('receive>> {0}'.format(recv_bytes.decode('UTF-8')))

    for i in ['A', 'B', 'C']:
        sock.send(i.encode('UTF-8'))
        recv_bytes = sock.recv(1024)
        print('receive>> {0}'.format(recv_bytes.decode('UTF-8')))

    sock.send('exit'.encode('UTF-8'))

    print('connect over')


if __name__ == '__main__':
    start_client()
